<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
  <title>订货单</title>
  <%= javascript_include_tag "prototype" %>
  <script language="javascript">
      function selectAgent(id)
       {
			var pars = 'id='+id;
			new Ajax.Request('/ajax/get_agent',{method:'get',parameters:pars,onComplete:addressResponse});
       }
       
      function addressResponse(response)
       {
        p = response.responseXML.getElementsByTagName("phone")[0];
        $('id_phone').value = p.firstChild.nodeValue;
        p = response.responseXML.getElementsByTagName("person")[0];
        $('id_person').value = p.firstChild.nodeValue;
        p = response.responseXML.getElementsByTagName("address1")[0];
        $('id_address1').value = p.firstChild.nodeValue;
       }
  </script>
</head>
<body>
<div style="text-align: center;">订货单<br>
</div>
<form action="/sale/add_sale_paper" method="post" name="salePaper">
<span id="test"></span>
<table style="text-align: left; width: 653px; height: 291px;" border="1" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td>购 买 方：</td>
      <td><select id="salePaper_agent_id" name="salePaper[agent_id]" onChange="selectAgent(this.value)"><%for agent in @agents%><option value="<%=agent.id%>" <%='selected="selected"' if agent.id==@salePaper.agent_id%>><%=agent.name%></option><%end%></td>
      <td>订单日期：</td>
      <td colspan="3"><%=select_date(@salePaper.sale_date_at,:use_month_numbers => true)%></td>
    </tr>
    <tr>
      <td>货运公司：</td>
      <td><%= text_field "salePaper", "transport_company", :value=>@salePaper.transport_company,:size => 30 %></td>
      <td>联 系 电 话：</td>
      <td><%= text_field "salePaper", "transport_company_phone", :value=>@salePaper.transport_company_phone,:size => 30 %></td>
      <td>保 险 金 额：</td>
      <td><%= text_field "salePaper", "amount_of_insurance", :value=>@salePaper.amount_of_insurance,:size => 20 %></td>
    </tr>
    <tr>
      <td>提 货 人： </td>
      <td><input type="text" id="id_person" name="salePaper[agent_people]" value="<%=@salePaper.agent_people%>" maxlength="20"/></td>
      <td>联系电话：</td>
      <td><input type="text" id="id_phone" name="salePaper[agent_phone]" value="<%=@salePaper.agent_phone%>" maxlength="20"/></td>
      <td>收货地址：</td>
      <td><input type="text" id="id_address1" name="salePaper[agent_address]" value="<%=@salePaper.agent_address%>" maxlength="20"/></td>
    </tr>
    <tr>
      <td>销售方：</td>
      <td colspan="2"><input type="text" name="salePaper[sale_company]" value="<%=@salePaper.sale_company%>" maxlength="20"/></td>
      <td>地址：</td>
      <td colspan="2"><input type="text" name="salePaper[sale_address]" value="<%=@salePaper.sale_address%>" maxlength="20"/></td>
    </tr>
    <tr>
      <td>TEL：</td>
      <td colspan="2"><input type="text" name="salePaper[sale_phone]" value="<%=@salePaper.sale_phone%>" maxlength="20"/></td>
      <td>FAX:</td>
      <td colspan="2"><input type="text" name="salePaper[sale_fax]" value="<%=@salePaper.sale_fax%>" maxlength="20"/></td>
    </tr>
    <tr align="center">
      <td colspan="6" rowspan="1">订货明细</td>
    </tr>
    <tr>
      <td colspan="6" rowspan="1">
      <table style="text-align: left; width: 642px; height: 166px;" border="1" cellpadding="2" cellspacing="2">
        <tbody>
          <tr>
            <td style="text-align: center;">序号</td>
            <td style="text-align: center;">产品型号</td>
            <td style="text-align: center;">数量</td>
            <td style="text-align: center;">单价</td>
            <td style="text-align: center;">小计</td>
            <td style="text-align: center;">备注</td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          <tr>
            <td style="text-align: center;">合计</td>
            <td style="text-align: center;"></td>
            <td style="text-align: center;">0</td>
            <td style="text-align: center;"></td>
            <td style="text-align: center;">0</td>
            <td style="text-align: center;"></td>
          </tr>
        </tbody>
      </table>
      </td>
    </tr>
    <tr>
      <td>打包件数:</td>
      <td colspan="2"><input type="text" name="salePaper[box_count]" value="<%=@salePaper.box_count%>" maxlength="20"/></td>
      <td>发货单号:</td>
      <td colspan="2"><input type="text" name="salePaper[serial]" value="<%=@salePaper.serial%>" maxlength="20"/></td>
    </tr>
    <tr>
      <td>发货通知:</td>
      <td colspan="5"><%=text_area(:salePaper, :memo,:text=>@salePaper.memo,:cols=>60,:rows=>10)%></td>
    </tr>
    <tr>
    	<td colspan="6"><input type="submit" value="添加"><input type="reset" value="重新填写"></td>
    </tr>
  </tbody>
</table>
</form>
<br>
</body>
</html>
